package syntaxTree;

import java.util.LinkedList;
import util.*;

public class Method
{ 
	Type t;
	Id id;
  LinkedList<Tuple<Type, Id>> forL;
	LinkedList<Tuple<Type, Id>> var;
	LinkedList<Stm> stms;
	Exp exp;
	
	public Method (Type t, Id id, LinkedList<Tuple<Type, Id>> forL, 
	  LinkedList<Tuple<Type, Id>> var, LinkedList<Stm> stms, Exp exp)
	{
		this.t= t;
		this.id = id;
		this.forL = forL;
		this.var = var;
		this.stms = stms;
		this.exp = exp;
	}
	public String toString()
	{
	String result = "";
    result += "public " + t.toString() + " " + id.toString();
    result += "(";
    for (Tuple<Type, Id> x:forL)
      result += x.toString();
    result += ")";
    result += "{\n";
    for (Tuple<Type, Id> x:var)
    {
      result += x.toString();
      result += ";\n"; 
    }
    result += ";\n";
    
    
    for (Stm s: stms)
    {
      result += s.toString();
    }
    result += "\n";
    
    
    result += "\treturn " + exp.toString();
    result += ";\n";
    result += "\t}\n";
    return result;
	}
	
	
	
}
